document.observe('dom:loaded', initSubmarine);

var tabs=['tabComplexity','tabCalls','tabDataUsage','tabReturns'];

var activetab = 0;
var bSidebar = false;

function initSubmarine()
{
	initMenuNeptuner();
	refreshTabs();
	$('sideBarContents').hide();
}

function initMenuNeptuner(){
	var myMenuItems = [
	  {
	    name: 'Goto Codebase Home',
	    className: 'edit',
	    callback: function() {
	      window.location = sNeptunerHome + "index.html";
	    }
	  },
	  {
	    name: 'Goto Source View',
	    className: 'delete',
	    callback: function() {
	    	window.location = sNeptunerHome + 'codebase/' + sFilename + '.uboat.html';
	    }
	  },
	  {
	    separator: true
	  },
	  {
	    name: 'About',
	    className: 'save',
	    callback: function() {
	      alert('Neptuner UBoat \n (C) 2009 The Oraclique \n Developed by SonOfDelphi');
	    }
	  }
	];

	new Proto.Menu({
	  selector: '#menuNeptuner', // context menu will be shown when element with id of "contextArea" is clicked
	  className: 'menu desktop', // this is a class which will be attached to menu container (used for css styling)
	  menuItems: myMenuItems, // array of menu items
	  activator: 'click'
	});
}

function refreshTabs()
{
	for(var i=0; i< tabs.length; i++){
		if(i==activetab){
			activateTab($(tabs[i]));
		}
		else{
			deactivateTab($(tabs[i]));
		}
	}
}

function activateTab(elmt)
{
	elmt.show();
}

function deactivateTab(elmt)
{
	elmt.hide();
}


function showComplexity()
{
	activetab=0;
	refreshTabs();
}

function showCalls()
{
	activetab=1;
	refreshTabs();
}

function showDataUsage()
{
	activetab=2;
	refreshTabs();
}

function showReturns()
{
	activetab=3;
	refreshTabs();
}

function toggleSidebar()
{
	//alert('sidebar');
	if(bSidebar==true){
		$('sideBarContents').hide();
		bSidebar=false;
	}
	else{
		$('sideBarContents').show();
		bSidebar=true;
	}
}